package com.hd.util;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

public class StringToolUtils {
    public static String escapeExprSpecialWord(String keyword) {
        if (keyword == null || keyword.equals("")) {
            return "";
        }
        String[] fbsArr = { "\\", "$", "(", ")", "*", "+", ".", "[", "]", "?", "^", "{", "}", "|" };
        for (String key : fbsArr) {
            if (keyword.contains(key)) {
                keyword = keyword.replace(key, "");
            }
        }
        return keyword;
    }

    public static boolean isNumeric(String str){
        for(int i=str.length();--i>=0;){
            int chr=str.charAt(i);
            if(chr<48 || chr>57)
                return false;
        }
        return true;
    }

    public static boolean isLetter(String str) {
        return str.matches("[a-zA-Z]+");
    }

    public static String implodeLongArray(String delimiter, List<Long> list) {
        List<String> stringList = new ArrayList<String>();
        if (list.size() <= 0) {
            return "";
        }
        for (Long id : list) {
            stringList.add(id.toString());
        }
        return String.join(delimiter, stringList);
    }
    
    /**
	 * 生成32位UUID
	 * @return
	 */
	public static String getUUID(){
	    return UUID.randomUUID().toString().trim().replaceAll("-", "");  
	}
}
